#include "spawn.h"
#include <assert.h>
#include <stdlib.h>

void room_spawn_layout (Segment* segment, Layout* layout, Generator* generator)
{
	int width = 7;
	int height = 7;
	segment->room[0] = generator->gen_room (layout, width, height, NULL, 0);
	segment->n_rooms = 1;
}

void room_spawn_content (Segment* segment, Layout* layout, Map* map,
                         Coord* entrance, int n_entrances,
                         Coord* exit, int n_exits)
{
	int room_id = segment->room[0];
	assert((room_id >= 0) && (room_id < layout->n_rooms));
	
	Rect* room = &layout->room[room_id].area;
	Coord spawn_coord = rect_middle (room);
	int spawn_id = map_add_spawn(map, spawn_coord);
	
	Tile* spawn_tile = &TILEC(map,spawn_coord);
	tile_make_spawn (spawn_tile, spawn_id);
	
#if TOWERHACK_DEBUG_OBJECTS
	Rect* room = &layout->room[room_id].area;
	Coord cbox1 = { room->left+3, room->top+3, room->z };
	MapObject* box1 = map_add_object (map, cbox1);
	map_object_make_treasure_gold (box1);
	segment_plant_obstacles (map, exit, n_exits);
#endif
}
